package bysj.service;

import bysj.dao.GraduateProjectStatusDao;
import bysj.domain.GraduateProjectStatus;
import util.JdbcHelper;
import util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

public final class GraduateProjectStatusService {
	private static GraduateProjectStatusDao graduateProjectStatusDao= GraduateProjectStatusDao.getInstance();
	private static GraduateProjectStatusService graduateProjectStatusService=new GraduateProjectStatusService();


	public static GraduateProjectStatusService getInstance(){
		return graduateProjectStatusService;
	}

	public Collection<GraduateProjectStatus> findAll(List conditionList,
												   Pagination pagination) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Collection<GraduateProjectStatus> graduateProjectTypes =
				graduateProjectStatusDao.finaAll(connection,conditionList,pagination) ;
		JdbcHelper.close(connection);
		return graduateProjectTypes;
	}

	public GraduateProjectStatus find(Integer id) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		GraduateProjectStatus graduateProjectStatus = graduateProjectStatusDao.find(id,connection);
		JdbcHelper.close(connection);
		return graduateProjectStatus;
	}

	public boolean update(GraduateProjectStatus graduateProjectStatus) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Boolean updated = graduateProjectStatusDao.update(graduateProjectStatus,connection);
		JdbcHelper.close(connection);
		return updated ;
	}

	public Integer add(GraduateProjectStatus graduateProjectStatus) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		int add_id = graduateProjectStatusDao.add(graduateProjectStatus,connection);
		JdbcHelper.close(connection);
		return add_id ;
	}
	public boolean delete(Integer id) throws SQLException{
		Connection connection = JdbcHelper.getConn();
		boolean deleted = graduateProjectStatusDao.delete(id, connection);
		JdbcHelper.close(connection);
		return deleted;
	}
}
